import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
import './forum_page/index.dart';
import './my_page/index.dart';
import './home_page/index.dart';
import './study_page/index.dart';

class PageIndex extends StatefulWidget {
  PageIndex({Key key}) : super(key: key);

  @override
  _PageIndexState createState() => _PageIndexState();
}

class _PageIndexState extends State<PageIndex> {
  int currentIndex = 2;
  List<Widget> optionList = [
    HomePage(),
    StudyPage(),
    ForumPage(),
    MyPage(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: this.currentIndex,
        children: this.optionList,
      ),
      bottomNavigationBar: BottomNavigationBar(
        fixedColor: Colors.blue,
        currentIndex: this.currentIndex,
        type: BottomNavigationBarType.fixed,
        onTap: (value) {
          setState(() {
            this.currentIndex = value;
          });
        },
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.change_history),
            label: '主页',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.flip_to_back),
            label: '学习',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.donut_large),
            label: '圈子',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.scatter_plot),
            label: '我的',
          ),
        ],
      ),
    );
  }
}
